package com.solver.mapper;

import com.solver.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart (name, image, user_id, question_id, field_id, question_difficulty, amount, create_time) " +
            "values (#{name},#{image},#{userId},#{questionId},#{fieldId},#{questionDifficulty},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    List<ShoppingCart> list(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void cleanShoppingCart(ShoppingCart shoppingCart);

    void sub(ShoppingCart shoppingCart);
}
